/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package slic.service.impl;

import java.util.Date;
import java.util.List;

import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.model.User;

import slic.model.Deportista;
import slic.model.Equipo;
import slic.model.Inscripcion;
import slic.service.base.InscripcionLocalServiceBaseImpl;
import slic.service.persistence.InscripcionUtil;

/**
 * The implementation of the Inscripcion local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link slic.service.InscripcionLocalService} interface.
 *
 * <p>
 * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
 * </p>
 *
 * @author Pablo Carballo
 * @see slic.service.base.InscripcionLocalServiceBaseImpl
 * @see slic.service.InscripcionLocalServiceUtil
 */
public class InscripcionLocalServiceImpl extends InscripcionLocalServiceBaseImpl {

	private static Log _log = LogFactoryUtil.getLog(InscripcionLocalServiceImpl.class);

	public Inscripcion add(Equipo equipo, Deportista deportista, User user) throws SystemException {

		Inscripcion inscripcion = InscripcionUtil.create(CounterLocalServiceUtil.increment());

		inscripcion.setEquipoId(equipo.getEquipoId());
		inscripcion.setDeportistaId(deportista.getDeportistaId());

		return InscripcionUtil.update(inscripcion, true);

	}

	public void delete(Equipo equipo, Deportista deportista) throws SystemException {
		InscripcionUtil.removeByEquipoIdAndDeportistaId(equipo.getEquipoId(), deportista.getDeportistaId());
	}

	public List<Inscripcion> findByDeportistaId(long deportistaId) throws SystemException {
		return InscripcionUtil.findByDeportistaId(deportistaId);
	}
	
	public List<Inscripcion> findByEquipoId(long equipoId) throws SystemException {
		return InscripcionUtil.findByEquipoId(equipoId);
	}

}
